package RecordManagement;

/*
 * When upper create/open a file, it will get a RM_FileHandle in return.
 * Client may conducts record manipulation through this handle.
 */
public interface RM_FileHandle_Interface {

	/*
	 * To get a Record, one must know the RID,
	 * which containing record position information in the file.
	 * Client may get the RID from FileScan or InsertRec.
	 */
	public RM_Record GetRec (RID rid);
	
	/* 
	 * The recordData must has recordSize bytes.
	 * Client may not worry about the organization, the manager will handle it.
	 * A RID will be returned to tell the position information.
	 */
	public RID InsertRec (byte[] recordData);
	
	public void DeleteRec (RID rid);
	
	/* 
	 * RM_Record contains RID, which contains postion information.
	 */
	public void UpdateRec (RM_Record rec);

	/*
	 * This method forces a page in the buffer written into the file.
	 */
	public void ForcePage (int pageNum);

	/*
	 * When the file is to be closed, a ForcePage method may be called.
	 * It forces all the pages in the buffer written into the file.
	 */
	public void ForceAllPages ();
	
	/*
	 * Get the number of records has been stored in the file.
	 */
	public int GetNumRecords();
	
	/*
	 * Get the number of pages has been allocated in the file.
	 * Notice that, if a page has been destoried, 
	 * the number of page allocated will decrease,
	 * but the actual file size will not shrink.
	 */
	public int GetNumPages();
}
